package com.ytjj.common.cmpp;

import com.huawei.insa2.util.Args;
import com.huawei.insa2.util.Cfg;
import com.xh.cmpp20.bean.LoginInfo;
import com.xh.cmpp20.bean.Message;
import com.xh.cmpp20.utils.Impl.MessageProxyImpl;

import java.io.IOException;
import java.util.Date;

public class SMProxyXHTools {
    private static String path=Thread.currentThread().getContextClassLoader().getResource("cmpp.xml").getPath().toString();

    public static void main(String[] args) {
        Args args1 = null;
        try {
            args1 = new Cfg("cmpp.xml").getArgs("CMPPConnect");
        } catch (IOException e) {
            e.printStackTrace();
        }
        LoginInfo loginInfo = new LoginInfo();
        loginInfo.setHost(args1.get("host", "127.0.0.1"));
        loginInfo.setPort(args1.get("port", "7890"));
        loginInfo.setSp_number(args1.get("sp_number", "400152"));
        loginInfo.setSource_addr(args1.get("source_addr", "400152"));
        loginInfo.setShared_secret(args1.get("shared_secret", "ktSrTiKC"));

        MessageProxyImpl smProxy = new MessageProxyImpl(loginInfo);
        boolean loginResult = smProxy.login(loginInfo);

        Message message = new Message();
        message.setMsgContent("你好呀");
        message.setPhoneNumber("18873058010");
        message.setReceiveTime(new Date());
        try {
            boolean result = smProxy.send(message);
            System.out.println(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
